package com.fruits.service.impl;

import com.fruits.dao.impl.FruitDaoImpl;
import com.fruits.domain.Fruit;
import com.fruits.dao.FruitDao;
import com.fruits.service.FruitService;

import java.util.List;

public class FruitServiceImpl implements FruitService {
    private FruitDao fruitDao=new FruitDaoImpl();
    @Override
    public List<Fruit> findHot() {

        return fruitDao.findHot();
    }

    @Override
    public Fruit findByFid(int fid) {
        return fruitDao.findByFid(fid);
    }

    @Override
    public List<Fruit> findByStr(String keyword) {
        return fruitDao.findByStr(keyword);
    }

    @Override
    public boolean add(Fruit fruit) {
      int num=fruitDao.add(fruit);
      if(num==1){
          return true;
      }else{
          return false;
      }
    }

    @Override
    public boolean update(Fruit fruit) {
        int num=fruitDao.update(fruit);
        if(num==1){
            return true;
        }else{
            return false;
        }
    }

    @Override
    public boolean delete(int fid) {
        int num=fruitDao.delete(fid);
        if(num==1){
            return true;
        }else{
            return false;
        }
    }

    @Override
    public List<Fruit> findAll() {
        return fruitDao.findAll();
    }

    @Override
    public List<Fruit> searchByOrigin() {
        return fruitDao.searchByOrigin();
    }

    @Override
    public List<Fruit> searchByChinaOrigin() {
        return fruitDao.searchByChinaOrigin();
    }

}
